﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mad.Core.Model
{
    public class TableItem
    {
        public string TableSchema { get; set; }
        public string TableName { get; set; }
        public string Item { get; set; }

        public TableItem(DataRow dataRow)
        {
            TableSchema = dataRow["TABLE_SCHEMA"].ToString();
            TableName = dataRow["TABLE_NAME"].ToString();
            Item = string.Concat(TableSchema, ".", TableName);
        }

        public TableItem(string item)
        {
            if (!string.IsNullOrEmpty(item))
            {
                string[] temp = item.Split(new string[]{"."}, StringSplitOptions.RemoveEmptyEntries);
                Item = item;
                TableSchema = temp[0];
                TableName = temp[1];
            }
        }
    }
}
